<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="翻译平台、翻译网站、找翻译、找人翻译、法语翻译、英语翻译、日语翻译、德语翻译、意大利语翻译、俄罗斯语、翻译人员、成都翻译、成都翻译员" />
<meta name="description" content="众译，助推翻译事业，选择最佳翻译人员，最迅速、最便捷的网络翻译平台。" />
<title>众译-可信赖的翻译平台-项目详情</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/reset.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/css.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/jquery.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/ui-lightness/jquery-ui-1.8.7.custom.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/config.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/citydata.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-ui-1.8.7.custom.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/chooselanguage.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/industry.js"></script>
<script type="text/javascript">
	var context = '<%=request.getContextPath()%>';
	
	var result = '<s:property value="#parameters.result"/>';
	
	var offering = '<s:property value="%{project.status == @com.transer.constant.Constants@PROJECT_STATUS_START}"/>';
	
	$(function(){
		replaceLanguage();
		calculateTime();
		$("#bid_project").bind('click', openDialog);
		$(".bidbtn").bind('click', bidProject);
		openMessageDialog();
	});
	
	function openMessageDialog() {
		if (!result.isEmpty()) {
			var message = null;
			switch (result) {
			case 'success':
				message = "竞标成功,请等待发布方回复.";
				break;
			case 'none':
				message = "你已经竞标过此项目,不能重复竞标.";
				break;
			case 'error':
				message = "竞标失败,请稍后再试.";
				break;
			case 'input':
				message = "该项目已结束竞标,不能对其竞标.";
				break;
			default:
				message = "不能对自己发布的项目进行竞标.";
				break;
			}
			if (message != null) {
				$("<div>"+message+"</div>").dialog({
					title:'提示消息',
					width: 650,
					resizable:false,
					draggable:false,
					modal: true,
					buttons:[
				         {
				        	 text : '确定',
				        	 click : function() {
				        		 $(this).dialog('close');
				        	 }
				         }
					]
				});
			}
		}
	}
	
	function bidProject() {
		var scheme = $("textarea[name='info.scheme']").val();
		var offer = $(":text[name='info.offer']").val();
		if (scheme.isEmpty()) {
			$("#erroMessage").text("竞标方案不能为空!");
			return;
		}
		if (!offer.isDigit()) {
			$("#erroMessage").text("竞标报价不能为空,并且只能为数字");
			return;
		}
		$("#erroMessage").html("<img src='"+context+"/images/loading.gif'/>正在提交竞标信息,请稍等....");
		$(".bidbtn").unbind('click', bidProject);
		$("#bid_form").submit();
	}
	
	function openDialog() {
		if (offering != 'true' || !offering) {
			$("<div>此项目已竞标结束,请找其它相关项目进行竞标.</div>").dialog({
				title:'提示消息',
				width: 650,
				resizable:false,
				draggable:false,
				modal: true,
				buttons:[
			         {
			        	 text : '确定',
			        	 click : function() {
			        		 $(this).dialog('close');
			        	 }
			         }
				]
			});
			return;
		}
		if (isLogin != 'true' || !isLogin) {
			$("<div>你还没有登陆,请先登陆之后才能竞标此项目</div>").dialog({
				title:'提示消息',
				width: 650,
				resizable:false,
				draggable:false,
				modal: true,
				buttons:[
			         {
			        	 text : '确定',
			        	 click : function() {
			        		 location.href = context + '/passport/login?jumpurl=' + location.href;
			        		 $(this).dialog('close');
			        	 }
			         },
			         {
			        	 text : '取消',
			        	 click : function() {
			        		 $(this).dialog('close');
			        	 }
			         }
				]
			});
			return;
		}
		$(".bid").dialog({
			title: "竞标此项目",
			width: 650,
			resizable:false,
			draggable:false,
			modal: true
		});
	}
	
	function replaceLanguage() {
		$(".lang_txt").each(function (index){
			var lang_id = $(this).text().split(",");
			var txt = new Array();
			for (var i = 0 ; i < lang_id.length; i++) {
				txt.push(getTranslate(lang_id[i]));
			}
			$(this).text(txt.join(","));
		});
	}
	
	var leftSeconds = parseInt('<s:property value="project.leftSeconds()"/>');
	leftSeconds = leftSeconds < 0 ? 0 : leftSeconds;
	var minuteSeconds = 60;
	var hourSeconds = 60 * minuteSeconds;
	var daySeconds = 24 * hourSeconds;
	var days = Math.floor(leftSeconds / daySeconds);
	var hour = Math.floor((leftSeconds % daySeconds) / hourSeconds);
	var minutes = Math.floor(((leftSeconds % daySeconds) % hourSeconds) / minuteSeconds);
	var seconds = ((leftSeconds % daySeconds) % hourSeconds) % minuteSeconds;
	
	function calculateTime() {
		if (leftSeconds <= 0) {
			$("#leftTime").html('0天');
			return;
		}
		leftSeconds --;
		days = Math.floor(leftSeconds / daySeconds);
		hour = Math.floor((leftSeconds % daySeconds) / hourSeconds);
		minutes = Math.floor(((leftSeconds % daySeconds) % hourSeconds) / minuteSeconds);
		seconds = ((leftSeconds % daySeconds) % hourSeconds) % minuteSeconds;
		$("#leftTime").html(days + '天' + hour + ':' + minutes + ':' + seconds);
		setTimeout(calculateTime, 1000);
	}
</script>
</head>
<body>
<div class="layout">
<jsp:include page="/include/head/top.jsp" /> 
<jsp:include page="/include/head/top_nav.jsp" />
<div></div>
<div class="content">
<div class="col_left">
<div class="project_detail">
<h1><s:property value="project.title"/> </h1>
<h2>
<s:if test="%{project.status == @com.transer.constant.Constants@PROJECT_STATUS_START && (#session.SESSION_USER == null || #session.SESSION_USER.type != @com.transer.constant.Constants@USER_TYPE_PUBLISHER)}">
	<span><a href="javascript:void(0)" id="bid_project">竞标此项目</a></span>
</s:if>
发布者<a href="<%=request.getContextPath()%>/search/publisher/<s:property value='project.userID'/>" target="_blank"><s:property value="project.nikeName"/> </a>
于 <s:text name="global.format.date"><s:param value="project.start"/></s:text> | 竞标人数 :<s:property value="project.offers.size()"/></h2>
<ul>
	<li><b>竞标剩余时间:</b><span id="leftTime"></span></li>
	<li><b>状态：</b>
	<s:if test="%{project.status == @com.transer.constant.Constants@PROJECT_STATUS_START}">
	<em>正在竞标</em>
	</s:if>
	<s:elseif test="%{project.status == @com.transer.constant.Constants@PROJECT_STATUS_END}">
	<em>竞标结束</em>
	</s:elseif>
	<s:elseif test="%{project.status == @com.transer.constant.Constants@PROJECT_STATUS_WORKING}">
	<em>工作进行中</em>
	</s:elseif>
	<s:elseif test="%{project.status == @com.transer.constant.Constants@PROJECT_STATUS_FINISH}">
	<em>项目完成</em>
	</s:elseif>
	</li>
	<li><b>翻译周期：</b><s:property value="project.workDays"/> 天</li>
	<li><b>类别：</b><span class="lang_txt"><s:property value="project.langFrom"/></span> -&gt; <span class="lang_txt"><s:property value="project.langTo"/></span></li>
	<li><b>预算：</b><b class="price"><s:property value="project.money"/>RMB</b></li>
	<li><b></b></li>
</ul>
<div class="description">
<p>
	<s:property value="project.desc"/>
</p>
</div>
<div class="project_bidding">
<table>
	<tr>
		<th>译员/翻译公司</th>
		<th>竞标日期</th>
		<th>状态</th>
	</tr>
	<s:iterator value="project.offers" var="offer">
		<tr>
			<td><a href="<%=request.getContextPath()%>/search/transer/<s:property value="#offer.user"/>"><s:property value="#offer.userName"/> </a></td>
			<td><s:text name="global.format.datetime"><s:param value="#offer.offerDate"/></s:text></td>
			<td>
			<s:if test="%{offer.isWin}">
				<em>中标</em>
			</s:if>
			<s:else>
				<em>竞标中</em>
			</s:else>
			</td>
		</tr>
	</s:iterator>
</table>
</div>

<div class="bid" style="display: none;">
	<form action="<%=request.getContextPath()%>/project/offer" id="bid_form" method="post" enctype="application/x-www-form-urlencoded">
		<table>
			<tbody>
			  <tr>
			    <td align="right"><span><b>*</b>创建竞标方案</span></td>
			    <td colspan="2"><textarea name="info.scheme"></textarea></td>
			    </tr>
			  <tr>
			    <td align="right"><b>*</b><span>竞标报价：</span></td>
			    <td><input type="text" class="intxt" name="info.offer"/><i>单位：RMB（人民币）</i></td>
			    <td>&nbsp;</td>
			  </tr>
			  <tr>
				   <td align="center" colspan="3">
				   <input type="hidden" value="<s:property value='project.id'/>" name="info.projectID"/>
				   <input type="button" class="bidbtn" value=""/>
				   </td>
			  </tr>
			  <tr>
				   <td align="center" colspan="3" id="erroMessage">
				   </td>
			  </tr>
			</tbody>
		</table>
	</form>
</div>
      
</div>
</div>
<div class="col_right">
<div class="user_info" style="margin: 0;">
<dl>
	<dt>
	<a href="<%=request.getContextPath()%>/search/publisher/<s:property value='project.userID'/>" target="_blank"><s:property value="project.nikeName"/> </a>
	</dt>
	<dd>注册日期：<s:text name="global.format.datetime"><s:param value="project.regDate"/></s:text></dd>
	<dd>上次登录：
		<s:if test="%{project.lastLoginTime != null}">
			<s:text name="global.format.datetime"><s:param value="project.lastLoginTime"/></s:text>
		</s:if>
	</dd>
	<dd>发布项目数：<s:property value="project.publishProjects"/></dd>
	<dd>评价：<span class="stars_<s:property value="project.averagePoint"/>"> </span></dd>
	<dd>累计支付金额：<b>￥<s:text name="global.format.money"><s:param value="project.totalMoney"/></s:text> RMB</b></dd>
</dl>
</div>
</div>
</div>
<jsp:include page="/include/foot/foot.jsp" />
</div>
</body>
</html>
